package batchsvg;

import java.util.Properties;

public class TextualValue {

    private String value;
    private String referencedValueKey;

    public TextualValue(String value) {
        this(value, null);
    }

    public TextualValue(String value, String referencedValueKey) {
        this.value = value;
        if( referencedValueKey != null && referencedValueKey.trim().length() > 0 ) {
            this.referencedValueKey = referencedValueKey;
        }
    }

    public String getValue() {
        return value;
    }

    public String getReferencedValueKey() {
        return referencedValueKey;
    }

    public String getValue(Properties valuesSoFar) {
        String value;
        if( referencedValueKey != null ) {
            value = valuesSoFar.getProperty(referencedValueKey);
            if( value == null ) {
                value = this.value;
            }
        } else {
            value = this.value;
        }
        return value;
    }
}
